import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
// import vue from '@vitejs/plugin-vue'
// import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import createVitePlugins from './vite/plugins'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    ...createVitePlugins(),
    ...[
      // AutoImport({
      //   resolvers: [ElementPlusResolver()]
      // }),
      // AutoImport({
      //   // 自动导入 Vue 相关函数，如：ref, reactive, toRef 等
      //   imports: ['vue'],
      //   dts: '/auto-import.d.ts',
      //   // eslintrc: {
      //   //   enabled: true
      //   //   // 1、改为true用于生成eslint配置。2、生成后改回false，避免重复生成消耗
      //   // }
      // }),
      Components({
        resolvers: [ElementPlusResolver()]
      })
    ]
  ],
  // plugins: [
  //   vue(),
  //   // ...
  //   AutoImport({
  //     resolvers: [ElementPlusResolver()]
  //   }),
  //   Components({
  //     resolvers: [ElementPlusResolver()]
  //   })
  // ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  }
})
